package com.ccb.sc.common.modules.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccb.sc.common.modules.order.convert.OrderConvert;
import com.ccb.sc.common.modules.order.entity.OrderRefund;
import com.ccb.sc.common.modules.order.mapper.OrderRefundMapper;
import com.ccb.sc.common.modules.order.vo.OrderRefundVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 退款单 服务实现类
 * </p>
 *
 * @author ken
 * @since 2020-09-25
 */
@Service
public class OrderRefundService extends ServiceImpl<OrderRefundMapper, OrderRefund> {

    public OrderRefundVo getByOrderReturnId(Long orderReturnId) {
        OrderRefund orderRefund = this.getOne(new QueryWrapper<OrderRefund>().lambda()
                .eq(OrderRefund::getOrderReturnId, orderReturnId)
                .orderByDesc(OrderRefund::getCreateTime)
                .last("limit 1"));
        return OrderConvert.INSTANCE.entity2RefundVo(orderRefund);
    }


}
